package org.example.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.example.JavaBean.plus.User;
import org.example.service.UserService;
import org.example.util.JsonResult;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:Liu
 * @Testname:AthController
 * @Date:2025/8/13 15:48
 */
@CrossOrigin
@RestController
@Slf4j
@RequestMapping("/ath")
public class AthController {

    @Resource
    private UserService userService;

    @PostMapping("/login")
    public JsonResult Login(User user) {
        return  userService.login(user);
    }

    @GetMapping("/is_login")
    public JsonResult isLogin(HttpServletRequest request) {
        return userService.isLogin(request.getHeader("token"));
    }


    @DeleteMapping("/loginout")
    public JsonResult logout(HttpServletRequest request) {
        return userService.Loginout(request.getHeader("token"));
    }
}
